/** @jsxImportSource @emotion/react */
import * as React from "react";
import {EvaluateItemConfig, RecordEvalArea} from "../config";

/**评估总得分 计算 本体安全状况分值为 分
 * 考虑：打一个权重对应的编辑区行个数太多了！ 编辑区拆分为多个的？ 原本et.weight!==undefined需加逻辑typeof et.weight === 'number'
 * */
export const useCalcEvalTotalScore= ({itRes, ItemArs}:{itRes:any, ItemArs:RecordEvalArea[]}
) => {
    const totalScore =React.useMemo(() => {
        let scoreSum=0;
        ItemArs?.forEach((area, b) => {
            area && area.items.forEach((et:EvaluateItemConfig, n:number) => {
                if(et){
                    if(et.weight!==undefined && typeof et.weight === 'number'){
                        let daxianFen=itRes?.[et.name+'_F'] || 0;
                        scoreSum+= daxianFen * et.weight;
                    }
                }
            });
        });
        return  scoreSum;
    }, [itRes,ItemArs]);
    return totalScore;
};
